package com.heny.demo.controller;

import com.heny.demo.service.ITurnPointService;
import com.heny.demo.util.FileUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequiredArgsConstructor
public class TurnPointController {

    private final ITurnPointService turnPointService;

    @PostMapping("/upload")
    public Boolean uploadTurnPoint(@RequestParam("turnPointFile") MultipartFile turnPointFile) throws IOException {
        // 获取文件后缀
        String fileType = FileUtil.getFileExtension(turnPointFile.getOriginalFilename());
        //返回执行结果
        return turnPointService.uploadTurnPoint(fileType, turnPointFile.getInputStream());
    }
}